﻿using RB.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using System.Data.Common;
using System.Linq.Expressions;
using System.Linq;
using System.Collections.Generic;
using RB.DataAccess.Linq;

namespace RB.DataAccess.Testing
{
    
    
    /// <summary>
    ///这是 ExecutorTest 的测试类，旨在
    ///包含所有 ExecutorTest 单元测试
    ///</summary>
    [TestClass()]
    public class ExecutorTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual Executor CreateExecutor()
        {
            // TODO: 实例化相应的具体类。
            Executor target = DataContext.CreateExecutor();
            return target;
        }

        /// <summary>
        ///BeginTransaction 的测试
        ///</summary>
        [TestMethod()]
        public void BeginTransactionTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            IsolationLevel iso = new IsolationLevel(); // TODO: 初始化为适当的值
            target.BeginTransaction(iso);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///BeginTransaction 的测试
        ///</summary>
        [TestMethod()]
        public void BeginTransactionTest1()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            target.BeginTransaction();
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///CommitTransaction 的测试
        ///</summary>
        [TestMethod()]
        public void CommitTransactionTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            target.CommitTransaction();
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        internal virtual Executor_Accessor CreateExecutor_Accessor()
        {
            // TODO: 实例化相应的具体类。
            Executor_Accessor target = null;
            return target;
        }

        /// <summary>
        ///CreateCommand 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem("RB.DataAccess.dll")]
        public void CreateCommandTest()
        {
            PrivateObject param0 = null; // TODO: 初始化为适当的值
            Executor_Accessor target = new Executor_Accessor(param0); // TODO: 初始化为适当的值
            string sql = string.Empty; // TODO: 初始化为适当的值
            DbCommand expected = null; // TODO: 初始化为适当的值
            DbCommand actual;
            actual = target.CreateCommand(sql);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///Delete 的测试
        ///</summary>
        public void DeleteTestHelper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, bool>> predict = null; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Delete<T>(predict);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void DeleteTest()
        {
            DeleteTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///Delete 的测试
        ///</summary>
        public void DeleteTest1Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            IQueryable<T> query = null; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Delete<T>(query);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void DeleteTest1()
        {
            DeleteTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Delete 的测试
        ///</summary>
        public void DeleteTest2Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, bool>> predict = null; // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Delete<T>(predict, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void DeleteTest2()
        {
            DeleteTest2Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Dispose 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem("RB.DataAccess.dll")]
        public void DisposeTest()
        {
            PrivateObject param0 = null; // TODO: 初始化为适当的值
            Executor_Accessor target = new Executor_Accessor(param0); // TODO: 初始化为适当的值
            bool disposing = false; // TODO: 初始化为适当的值
            target.Dispose(disposing);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///Dispose 的测试
        ///</summary>
        [TestMethod()]
        public void DisposeTest1()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            target.Dispose();
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///Execute 的测试
        ///</summary>
        [TestMethod()]
        public void ExecuteTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            string sql = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Execute(sql);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///ExecuteQuery 的测试
        ///</summary>
        //public void ExecuteQueryTestHelper<T>()
        //{
        //    Executor target = CreateExecutor(); // TODO: 初始化为适当的值
        //    Expression expression = null; // TODO: 初始化为适当的值
        //    IEnumerable<T> expected = null; // TODO: 初始化为适当的值
        //    IEnumerable<T> actual;
        //    actual = target.ExecuteQuery<T>(expression);
        //    Assert.AreEqual(expected, actual);
        //    Assert.Inconclusive("验证此测试方法的正确性。");
        //}

        //[TestMethod()]
        //public void ExecuteQueryTest()
        //{
        //    ExecuteQueryTestHelper<GenericParameterHelper>();
        //}

        /// <summary>
        ///ExecuteQuery 的测试
        ///</summary>
        public void ExecuteQueryTest1Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            string querySql = string.Empty; // TODO: 初始化为适当的值
            IEnumerable<T> expected = null; // TODO: 初始化为适当的值
            IEnumerable<T> actual;
            actual = target.ExecuteQuery<T>(querySql);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void ExecuteQueryTest1()
        {
            ExecuteQueryTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///ExecuteReader 的测试
        ///</summary>
        [TestMethod()]
        public void ExecuteReaderTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            string sql = string.Empty; // TODO: 初始化为适当的值
            IDataReader expected = null; // TODO: 初始化为适当的值
            IDataReader actual;
            actual = target.ExecuteReader(sql);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///ExecuteScalar 的测试
        ///</summary>
        [TestMethod()]
        public void ExecuteScalarTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            string sql = string.Empty; // TODO: 初始化为适当的值
            object expected = null; // TODO: 初始化为适当的值
            object actual;
            actual = target.ExecuteScalar(sql);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///ExecuteScalar 的测试
        ///</summary>
        public void ExecuteScalarTest1Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression expression = null; // TODO: 初始化为适当的值
            T expected = default(T); // TODO: 初始化为适当的值
            T actual;
            actual = target.ExecuteScalar<T>(expression);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void ExecuteScalarTest1()
        {
            ExecuteScalarTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Finalize 的测试
        ///</summary>
        //[TestMethod()]
        //[DeploymentItem("RB.DataAccess.dll")]
        //public void FinalizeTest()
        //{
        //    PrivateObject param0 = null; // TODO: 初始化为适当的值
        //    Executor_Accessor target = new Executor_Accessor(param0); // TODO: 初始化为适当的值
        //    target.Finalize();
        //    Assert.Inconclusive("无法验证不返回值的方法。");
        //}

        /// <summary>
        ///Insert 的测试
        ///</summary>
        public void InsertTestHelper<T, TFields>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, TFields>> fields = null; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Insert<T, TFields>(fields);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void InsertTest()
        {
            InsertTestHelper<GenericParameterHelper, GenericParameterHelper>();
        }

        /// <summary>
        ///Insert 的测试
        ///</summary>
        public void InsertTest1Helper<TFields>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            IQueryable<TFields> query = null; // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Insert<TFields>(query, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void InsertTest1()
        {
            InsertTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Insert 的测试
        ///</summary>
        public void InsertTest2Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            T entity = default(T); // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Insert<T>(entity);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void InsertTest2()
        {
            InsertTest2Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Insert 的测试
        ///</summary>
        public void InsertTest3Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            T entity = default(T); // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Insert<T>(entity, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void InsertTest3()
        {
            InsertTest3Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Insert 的测试
        ///</summary>
        public void InsertTest4Helper<T, TFields>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, TFields>> fields = null; // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Insert<T, TFields>(fields, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void InsertTest4()
        {
            InsertTest4Helper<GenericParameterHelper, GenericParameterHelper>();
        }

        [TestMethod()]
        public void InsertByteArray()
        {
            Executor target = CreateExecutor();
            TestType1 t = new TestType1();
            t.VarBinData = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 };
            int expected = 1;
            int actual = target.Insert<TestType1>(t);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///Query 的测试
        ///</summary>
        public void QueryTestHelper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            SqlQueryable<T> expected = null; // TODO: 初始化为适当的值
            SqlQueryable<T> actual;
            actual = target.Query<T>();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void QueryTest()
        {
            QueryTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///Query 的测试
        ///</summary>
        public void QueryTest1Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            SqlQueryable<T> expected = null; // TODO: 初始化为适当的值
            SqlQueryable<T> actual;
            actual = target.Query<T>(mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void QueryTest1()
        {
            QueryTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///RollbackTransaction 的测试
        ///</summary>
        [TestMethod()]
        public void RollbackTransactionTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            target.RollbackTransaction();
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///Update 的测试
        ///</summary>
        public void UpdateTestHelper<T, TFields>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, TFields>> fields = null; // TODO: 初始化为适当的值
            IQueryable<T> query = null; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Update<T, TFields>(fields, query);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void UpdateTest()
        {
            UpdateTestHelper<GenericParameterHelper, GenericParameterHelper>();
        }

        /// <summary>
        ///Update 的测试
        ///</summary>
        public void UpdateTest1Helper<T, TFields>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            Expression<Func<T, TFields>> fields = null; // TODO: 初始化为适当的值
            Expression<Func<T, bool>> predict = null; // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Update<T, TFields>(fields, predict, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void UpdateTest1()
        {
            UpdateTest1Helper<GenericParameterHelper, GenericParameterHelper>();
        }

        /// <summary>
        ///Update 的测试
        ///</summary>
        public void UpdateTest2Helper<T>()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            T entity = default(T); // TODO: 初始化为适当的值
            Expression<Func<T, bool>> predict = null; // TODO: 初始化为适当的值
            string mappingTo = string.Empty; // TODO: 初始化为适当的值
            int expected = 0; // TODO: 初始化为适当的值
            int actual;
            actual = target.Update<T>(entity, predict, mappingTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod()]
        public void UpdateTest2()
        {
            UpdateTest2Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///Connection 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem("RB.DataAccess.dll")]
        public void ConnectionTest()
        {
            PrivateObject param0 = null; // TODO: 初始化为适当的值
            Executor_Accessor target = new Executor_Accessor(param0); // TODO: 初始化为适当的值
            DbConnection actual;
            actual = target.Connection;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///DataContext 的测试
        ///</summary>
        [TestMethod()]
        public void DataContextTest()
        {
            Executor target = CreateExecutor(); // TODO: 初始化为适当的值
            DataContext actual;
            actual = target.DataContext;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
    }
}
